<?php

/**
 * Manage ask
 *
 * @package    letsManager
 * @subpackage form
 * @author     Jerome Fouilloy
 * @version    SVN: $Rev$
 */
abstract class PluginLetsUserAskForm extends BaseLetsUserAskForm
{
  public function setup()
  {
  	parent::setup();
	$context = $this->getOption('context');
	
	$this->useFields(array('name','category_id','id'));

	$user = $context->getUser();
	$this->widgetSchema['category_id']->setOption('query', LetsMainCategoryTable::getQueryForUser($user,false));
	// we can't modify delay expiration
	if($this->getObject()->isNew())
	{
		$this->widgetSchema['delay_expiration']	= new sfWidgetFormChoice(
		array(
			'multiple' => false,
			'choices' => LetsUserAskTable::getExpirationDelays()
		));
		$this->validatorSchema['delay_expiration'] = new sfValidatorChoice(
		array(
			'choices' => LetsUserAskTable::getExpirationDelaysValue()
		));
	}
/*	$context->getConfiguration()->loadHelpers("Asset");
	$dateForm = new sfWidgetFormDate(array(
	  'format'  => '%day%.%month%.%year%',
      'years'   => DateTools::rangeOfYears(date('Y'), 2000)
	));
	
	$this->widgetSchema['date_expiration'] = new sfWidgetFormJQueryDate(array(
      'image'   => PiwamAccessor::iconPathCalendar(),
      'config'  => '{}',
      'culture' => 'fr_FR',
	  'date_widget' => $dateForm
    ));*/
	
    //$this->widgetSchema['name'] = new sfWidgetFormTextareaTinyMCE(array('width' => '400px', 'height' => '250px', 'theme'=> 'simple'));
	$this->widgetSchema['name']->setAttribute('class', 'formInputLarge');

	$this->widgetSchema->setLabels(array(
      'name'   => 'Description',
	  'category_id' => 'Catégorie',
	  'delay_expiration' => 'Valable pendant',
    ));
  }	
}
